//
// Created by wangbo on 9/22/18.
//

#ifndef TWO_FORKED_TREE_ERGODIC_H
#define TWO_FORKED_TREE_ERGODIC_H

#include <iostream>
#include <vector>
using namespace std;
//Definition for a binary tree node.
struct Node {
    int val;
    Node *left;
    Node *right;
    Node(int x) : val(x), left(NULL), right(NULL) {}
};

typedef struct Node TNode;    //定义二叉树节点 (方式一)
typedef TNode *BTree;         //定义二叉树链表（方式二）

class ergodic {
    public:
    void front_bianli(BTree root);//前序遍历递归版本
    void front_bianli1(BTree root);//前序遍历非递归版本
    void front_bianli2(BTree root);//前序遍历非递归版


    void inorder_traversal(BTree root);//中序遍历递归版本
    void inorder_traversal1(BTree root);//中序遍历非递归版本

    void back_travelsal(BTree root);//后续遍历递归版本
    void back_travelsal1(BTree root);//后续遍历非递归版本

    void sequence_traversal(BTree root);
    BTree make_a_tree(vector<int> &nums);//建树

    private:
        BTree gen_head(vector<int> &nums, int index){
                if(index + 1>nums.size())return NULL;
                BTree tem = new Node(nums[index]);
                return tem;
        }//生成树的节点。
};


#endif //TWO_FORKED_TREE_ERGODIC_H
